<template>
    <div>
        <el-table :data='exData' id="tableData1" style="display: none;">
            <el-table-column prop='companyHsName' label='单位名称'></el-table-column>
            <el-table-column prop='companyHsCode' label='海关编码'></el-table-column>

            <el-table-column prop='address' label='地址'></el-table-column>
            <el-table-column prop='contactsName' label='订单专管员'></el-table-column>
            <el-table-column prop='contactsPhone' label='专管员手机'></el-table-column>
        </el-table>
        <el-table :data='exData2' id="tableData2" style="display: none;">
            <el-table-column prop='companyName' label='单位名称'></el-table-column>
            <el-table-column prop='companyHsCode' label='海关编码'></el-table-column>

            <el-table-column prop='address' label='地址'></el-table-column>
            <el-table-column prop='tradeMode' label='贸易方式'></el-table-column>
            <el-table-column prop='responPerson' label='负责人'></el-table-column>
            <el-table-column prop='responPersonOfficePhone' label='联系电话'></el-table-column>
            <el-table-column prop='responPersonPhone' label='负责人手机'></el-table-column>
        </el-table>
        <el-tabs style='margin-left: 10px'>
            <el-tab-pane label='已激活企业列表'>
                <div class='container'
                     v-loading="Tloading"
                     :element-loading-text="tText"
                     element-loading-spinner="el-icon-loading">
                    <el-form ref='form' :model='filterForm'>
                        <el-form-item>
                            <el-select
                                    v-model='filterForm.timeScope'
                                    placeholder='全部'
                                    filterable
                                    clearable
                                    style='width: 200px;'
                            >
                                <el-option
                                        v-for='item in timeScopes'
                                        :key='item.id'
                                        :label='item.name'
                                        :value='item.id'
                                ></el-option>
                            </el-select>
                            <el-input
                                    v-model='filterForm.name'
                                    placeholder='企业名称'
                                    class='normal-input'
                                    style='width: 175px; margin-left: 10px;'
                            ></el-input>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-search'
                                    @click='handleFilter(0)'
                                    style='margin-left: 10px;'
                            >筛选
                            </el-button>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-refresh'
                                    @click='handleFilter(1)'
                                    style='margin-left: 10px;'
                            >重置
                            </el-button>
                            <div style='float: right;'>
                                <el-button
                                        class='filter-item'
                                        type='primary'
                                        plain
                                        icon='el-icon-message'
                                        @click="oneReport"
                                >一键催报
                                </el-button>
                                <!--<el-button class='filter-item' type='primary' plain icon='el-icon-document' @click='handleExcel'>导出</el-button>-->
                                <el-button class='filter-item' type='primary' plain icon='el-icon-document' @click='handleExcel'>导出</el-button>
                            </div>
                        </el-form-item>
                    </el-form>
                    <br/>
                    <el-table
                            :data='companyList'
                            border
                            fit
                            el-tabl
                            stripe
                            id='table-data'
                            style='width: 100%;'
                    >
                        <el-table-column prop='id' align='center' label='编号' width='0' v-if='false'></el-table-column>
                        <el-table-column prop='companyrName' align='center' min-width='100px'
                                         label='单位名称'></el-table-column>
                        <el-table-column prop='address' align='center' min-width='150px' label='地址'></el-table-column>
                        <el-table-column prop='name' align='center' min-width='70px' label='订单专管员'></el-table-column>
                        <el-table-column prop='phone' align='center' min-width='70px' label='专管员手机'></el-table-column>
                        <el-table-column prop='contact' align='center' min-width='70px' label='企业负责人'></el-table-column>
                        <el-table-column prop='contactphone' align='center' min-width='70px'
                                         label='联系电话'></el-table-column>
                        <el-table-column prop='password' align='center' min-width='70px' label='密码'>
                            <template slot-scope='scope'>
                                <el-button size='small' type='primary' plain @click='handlePass(scope.row)'>重置密码
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column prop='status' align='center' min-width="280" label='操作'>
                            <template slot-scope='scope'>
                                <el-button size='small' type='primary' plain @click='handleView(scope.row)'>出口订单
                                </el-button>
                                <el-button size='small' type='primary' plain @click='reportIdHandle(scope.row)'>催报</el-button>
                                <el-button size='small' type='primary' plain @click='useHandle(scope.row.id)'>停用</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class='pagination-container'>
                        <el-pagination
                                background
                                layout='total, prev, pager, next'
                                :total='total'
                                :page-count='count'
                                :page-size='size'
                                :current-page='pageCurrent'
                                @current-change='handleCurrentChange'
                        ></el-pagination>
                    </div>
                </div>
            </el-tab-pane>
            <el-tab-pane label='未激活企业列表'>
                <div class='container'
                     v-loading="Tloading2"
                     :element-loading-text="tText2"
                     element-loading-spinner="el-icon-loading">
                    <el-form ref='form' :model='filterFormN'>
                        <el-form-item>
                            <el-input
                                    v-model='filterFormN.name'
                                    placeholder='企业名称'
                                    class='normal-input'
                                    style='width: 175px; margin-left: 10px;'
                            ></el-input>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-search'
                                    @click='handleFilterN(0)'
                                    style='margin-left: 10px;'
                            >筛选
                            </el-button>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-refresh'
                                    @click='handleFilterN(1)'
                                    style='margin-left: 10px;'
                            >重置
                            </el-button>
                            <el-button class='filter-item' type='primary' plain icon='el-icon-document' @click='handleExcel2' style='float: right;'>导出</el-button>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-plus'
                                    @click='handleCreate'
                                    style='float: right;'
                            >新增企业
                            </el-button>
                        </el-form-item>
                    </el-form>
                    <el-table
                            :data='companyListN'
                            border
                            fit
                            el-tabl
                            stripe
                            id='table-dataN'
                            style='width: 100%;'
                    >
                        <el-table-column prop='id' align='center' label='编号' width='0' v-if='false'></el-table-column>
                        <el-table-column prop='companyrName' align='center' min-width='100px'
                                         label='单位名称'></el-table-column>
                        <el-table-column prop='address' align='center' min-width='150px' label='地址'></el-table-column>
                        <el-table-column prop='tradeMode' align='center' min-width='100px'
                                         label='贸易方式'></el-table-column>
                        <el-table-column prop='responPerson' align='center' min-width='70px'
                                         label='负责人'></el-table-column>
                        <el-table-column
                                prop='responPersonOfficePhone'
                                align='center'
                                min-width='80px'
                                label='联系电话'
                        ></el-table-column>
                        <el-table-column prop='responPersonPhone' align='center' min-width='80px'
                                         label='负责人手机'></el-table-column>
                        <el-table-column prop='status' align='center' label='操作'>
                            <template slot-scope='scope'>
                                <el-button size='small' type='primary' plain @click='useHandle2(scope.row.id)'>停用</el-button>
                            </template>
                        </el-table-column>
                        <!--<el-table-column align='center' label='操作'>
                          <template slot-scope='scope'>
                            <el-button size='mini' type='danger' @click='handleDelete(scope.$index, scope.row)'>删除</el-button>
                          </template>
                        </el-table-column>-->
                    </el-table>
                    <div class='pagination-container'>
                        <el-pagination
                                background
                                layout='total, prev, pager, next'
                                :total='totalN'
                                :page-count='countN'
                                :page-size='sizeN'
                                :current-page='pageCurrentN'
                                @current-change='handleCurrentChangeN'
                        ></el-pagination>
                    </div>
                </div>
            </el-tab-pane>
            <el-tab-pane label='已停用企业列表'>
                <div class='container'
                     v-loading="Tloading3"
                     element-loading-text="正在加载一大波数据，请稍后···"
                     element-loading-background="rgba(0, 0, 0, 0.8)"
                     element-loading-spinner="el-icon-loading">
                    <el-form ref='form' :model='filterForm'>
                        <el-form-item>
                            <el-input
                                    v-model='sName'
                                    placeholder='企业名称'
                                    class='normal-input'
                                    style='width: 175px; margin-left: 10px;'
                            ></el-input>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-search'
                                    @click='initStopCorpListSearch(sName)'
                                    style='margin-left: 10px;'
                            >筛选
                            </el-button>
                            <el-button
                                    class='filter-item'
                                    type='primary'
                                    plain
                                    icon='el-icon-refresh'
                                    @click='resetHandle'
                                    style='margin-left: 10px;'
                            >重置
                            </el-button>
                        </el-form-item>
                    </el-form>
                    <br/>
                    <el-table
                            :data='StopCompanyList'
                            border
                            fit
                            el-tabl
                            stripe
                            id='table-data'
                            style='width: 100%;'
                    >
                        <el-table-column prop='id' align='center' label='编号' width='0' v-if='false'></el-table-column>
                        <el-table-column prop='companyName' align='center' min-width='100px' label='单位名称'></el-table-column>
                        <el-table-column prop='address' align='center' min-width='150px' label='地址'></el-table-column>
                        <el-table-column prop='responPerson' align='center' min-width='70px' label='负责人'></el-table-column>
                        <el-table-column prop='responPersonPhone' align='center' min-width='70px' label='负责人电话'></el-table-column>
                        <el-table-column prop='meno' align='center' min-width='70px' label='企业停用理由'></el-table-column>
                        <el-table-column prop='status' align='center' label='操作'>
                            <template slot-scope='scope'>
                                <el-button size='small' type='primary' @click="reUseHandle(scope.row.id)" plain>启用</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class='pagination-container'>
                        <el-pagination
                                background
                                layout='total, prev, pager, next'
                                :total='Stotal'
                                :page-count='Scount'
                                :page-size='Ssize'
                                :current-page='SpageCurrent'
                                @current-change='ShandleCurrentChange'
                        ></el-pagination>
                    </div>
                </div>
            </el-tab-pane>
        </el-tabs>
        <div>
            <el-dialog title="一键催报内容确认" :visible.sync="report" :before-close="handleCloseOne">
                <div style="background:#ebeef5;padding: 20px;border-radius: 6px;">
                    <P>请选择未申报的时间 ( 不选则默认不限制时间 )
                    </P>
                    <el-radio @change="getValue" v-model="radio" label="15">半个月</el-radio>
                    <el-radio @change="getValue" v-model="radio" label="30">一个月</el-radio>
                    <el-radio @change="getValue" v-model="radio" label="90">三个月</el-radio>
                    <el-radio @change="getValue" v-model="radio" label="180">六个月</el-radio>
                    <el-radio @change="getValue" v-model="radio" label="365">一年</el-radio>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <el-button type="text" @click="clearRadio">清空所选</el-button>
                </div>
                <br/>
                <div>
                    <p>在催报之前，请确认短信模板，可根据自己需要做修改。</p>
                    <p style="color: #F56C6C;font-weight: bold;">企业名称使用"@"代替，发送时会自动转换成企业名称。</p>
                    <el-input :rows="4" v-model="msgModel" type="textarea"></el-input>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="handleCloseOne">取 消</el-button>
                    <el-button type="primary" @click="oneReportConfirm">确认一键催报</el-button>
                </div>
            </el-dialog>
        </div>
        <div>
            <el-dialog
                    title="催报信息确认"
                    :visible.sync="chooseShow"
                    width="30%"
                    :before-close="handleClose">
                <p>在催报之前，请确认短信模板，可根据自己需要做修改。<br/></p>
                <p style="color: #F56C6C;font-weight: bold;">企业名称使用"@"代替，发送时会自动转换成企业名称。</p>
                <el-input :rows="4" v-model="msgModel" type="textarea"></el-input>
                <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose">取 消</el-button>
                <el-button type="primary" @click="reportIdConfirm">确 定</el-button>
             </span>
            </el-dialog>
        </div>
    </div>
</template>
<script>
    import {getCorpList, getCorpListN, resetPassWord, delData, Report,OneReport,companyAStopUse,companyStopUse,stopCompanyList,reUserFn} from '@/api/corp';
    import {EgetCorpList,EgetCorpListN} from '@/api/corp'; //导出
    import FileSaver from 'file-saver';
    import XLSX from 'xlsx';

    export default {
        data() {
            return {
                tText:'正在加载数据，请稍后...',
                tText2:'正在加载数据，请稍后...',
                exData:[],
                exData2:[],
                sName:'',
                notApplyDay:'',
                companyId: '',
                chooseShow: false,
                msgModel: '',
                report: false,
                radio: '',
                Tloading: true,
                Tloading2: true,
                Tloading3: true,
                filterForm: {
                    timeScope: '',
                    name: ''
                },
                filterFormN: {
                    name: ''
                },
                timeScopes: [
                    {
                        id: '365',
                        name: '1年无提交'
                    },
                    {
                        id: '180',
                        name: '6月无提交'
                    },
                    {
                        id: '90',
                        name: '3个月无提交'
                    },
                    {
                        id: '30',
                        name: '1个月无提交'
                    },
                    {
                        id: '15',
                        name: '半个月无提交'
                    }
                ],
                companyList: [],
                StopCompanyList:[],
                filter: false,
                total: 0,
                count: 0,
                pageCurrent: 1,
                size: 10,
                companyListN: [],
                filterN: false,
                totalN: 0,
                countN: 0,
                pageCurrentN: 1,
                sizeN: 10,

                Stotal: 0,
                Scount: 0,
                SpageCurrent: 1,
                Ssize: 10,
            };
        },
        created() {
            this.initCorpList('1');
            this.initCorpListN('1');
            this.initStopCorpList('1');
        },
        methods: {
            resetHandle(){
              this.sName = '';
                this.initStopCorpList(1)
            },
            initStopCorpListSearch(sName){
                this.initStopCorpList(1,sName);
            },
            reUseHandle(id){
                if(id){
                    reUserFn(id).then(res=>{
                        if(res.code == 0){
                            this.initStopCorpList(1);
                            this.initCorpList(1);
                            this.initCorpListN(1);
                        }else{
                            this.$message.error(res.msg)
                        }
                    })
                }else{
                    this.$message.error('系统错误，请联系管理员')
                }
                console.log(id)
            },
            initStopCorpList(pageCurrent,sName){
                this.Tloading3= true;
                stopCompanyList(pageCurrent,sName).then(res=>{
                    if(res.code ==0){
                        this.Tloading3= false;
                        this.StopCompanyList = res.data;
                            this.Stotal = res.page.resultCount;
                            this.Scount = res.page.pageCount
                            this.SpageCurrent = res.page.pageCurrent
                            this.Ssize = res.page.pageLimit
                    }else {
                        this.$message.error(res.msg)
                    }
                })
            },
            useHandle(id){
                let that = this;
                this.$prompt('请输入停用理由', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
                    inputErrorMessage: '停用理由不能为空'
                }).then(({ value }) => {
                    companyAStopUse(id,value).then(res=>{
                        if(res.code ==0){
                            this.initCorpList(that.pageCurrent);
                            this.$message({
                                type: 'success',
                                message: '停用成功'
                            });
                            this.initStopCorpList(1);
                        }else{
                            this.$message.error(res.msg)
                        }

                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消操作'
                    });
                });

            },
            useHandle2(id){
                let that = this;
                this.$prompt('请输入停用理由', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
                    inputErrorMessage: '停用理由不能为空'
                }).then(({ value }) => {
                    companyStopUse(id,1,value).then(res=>{
                        if(res.code ==0){
                            this.initCorpListN(that.pageCurrent);
                            this.$message({
                                type: 'success',
                                message: '停用成功'
                            });
                            this.initStopCorpList(1);
                        }else{
                            this.$message.error(res.msg)
                        }

                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消操作'
                    });
                });



            },
            getValue(val){
                this.notApplyDay = val;
                console.log(val)
            },
            oneReport() {
                this.report = !this.report;
                this.msgModel = `尊敬的@，根据《浙江省商务厅关于扎实做好浙江省出口订单在线管理系统落实推进工作的通知》要求，请登录 http://or.dc.zjmade.cn 完成在手订单填报`;
            },
            clearRadio() {
                this.radio = '';
                this.notApplyDay = '';

            },
            oneReportConfirm() {
                OneReport(this.notApplyDay,this.msgModel).then(res => {
                    if (res.code == 0) {
                        this.$message({
                            type: 'success',
                            message: "一键催报成功"
                        })
                    } else {
                        this.$message.error(res.msg)
                    }
                }).catch(err => {
                    this.$message.error(err)
                })

            },
            handleCloseOne() {
                this.report = !this.report;
                this.msgModel = '';
                this.notApplyDay = '';
            },
            handleClose() {
                this.chooseShow = !this.chooseShow;
                this.msgModel = '';
                this.companyId = '';
            },
            reportIdHandle(row) {
                console.log(row)
                let id = row.id;
                id = `["${id}"]`;
                let oText = row.companyrName;
                this.msgModel = `尊敬的@，根据《浙江省商务厅关于扎实做好浙江省出口订单在线管理系统落实推进工作的通知》要求，请登录 http://or.dc.zjmade.cn 完成在手订单填报`
                this.companyId = id;
                this.chooseShow = !this.chooseShow;
            },
            reportIdConfirm() {
                Report(this.companyId, this.msgModel).then(res => {
                    if (res.code == 0) {
                        this.$message({
                            type: 'success',
                            message: "已催报"
                        })
                    } else {
                        this.$message.error(res.msg)
                    }
                }).catch(err => {
                    this.$message.error(err)
                })
            },
            handleDelete(index, row) {
                let id = row.id;
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    delData(id).then(res => {
                        if (res.code == 0) {
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            this.initCorpList('1');
                            this.initCorpListN('1');
                        } else {
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                        }
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },
             // 已激活企业列表导出
            handleExcel(){
                this.Tloading =  true;
                this.tText = '当前操作最大支持5000条数据导出，可能耗时较久，请耐心等待。'
                let page = 1;
                let that = this;
                let pagec
                var name = '';
                var timeScope = '';
                let pageLimit = 500;
                async function gofn(){
                    let arr = [];
                    let num = 0;
                    let Result = await EgetCorpList(page, '', '', 1);
                    let result =Result.page.resultCount
                    num = Math.ceil(result / 500);
                    if(num>10){
                        num =10;
                        // that.$notify({
                        //     title: '导出提醒',
                        //     message: '当前系统最大支持导出5000条数据',
                        //     type: 'warning'
                        // });
                    }
                    for (var i=0;i<num;i++){
                        let r = await EgetCorpList(i+1, '', '', pageLimit);
                        let r2 = r.data;
                        arr = arr.concat(r2)

                    }
                    that.exData = arr;
                    setTimeout(function () {
                        countHandle('#tableData1',that);
                    },200)
                    function countHandle(id,that) {
                        // this.$router.push({name: 'export'})
                        /!* generate workbook object from table *!/
                        var wb = XLSX.utils.table_to_book(document.querySelector(id));
                        /!* get binary string as output *!/
                        var wbout = XLSX.write(wb, {
                            bookType: 'xlsx',
                            bookSST: true,
                            type: 'array'
                        });
                        try {
                            FileSaver.saveAs(
                                new Blob([wbout], { type: 'application/octet-stream' }),
                                `已激活企业列表数据.xlsx`
                            );
                        } catch (e) {
                            if (typeof console !== 'undefined') console.log(e, wbout);
                        }
                        that.Tloading = false;
                        return wbout;
                    }
                }
                gofn()

            },
            // 未激活企业列表导出

            handleExcel2(){
                this.Tloading2 =  true;
                this.tText2 = '当前操作最大支持5000条数据导出，可能耗时较久，请耐心等待。'
                // this.$notify({
                //     title: '导出提醒',
                //     message: '正在执行导出操作，大约要1~3分钟。刷新浏览器可以取消导出操作！',
                //     type: 'warning'
                // });
                let page = 1;
                let that = this;
                let pagec
                var name = '';
                var timeScope = '';
                let pageLimit = 500;
                async function gofn2(){
                    let arr = [];
                    let num = 0;
                    let Result = await EgetCorpListN(page, '', 1);
                    let result =Result.page.resultCount
                    num = Math.ceil(result / 500);
                    if(num>10){
                        num =10;
                        // that.$notify({
                        //     title: '导出提醒',
                        //     message: '当前系统最大支持导出5000条数据',
                        //     type: 'warning'
                        // });
                    }
                    for (var i=0;i<num;i++){
                        let r = await EgetCorpListN(i+1, '', pageLimit);
                        let r2 = r.data;
                        arr = arr.concat(r2)

                    }
                    that.exData2 = arr;
                    setTimeout(function () {
                        countHandle('#tableData2',that);
                    },200)
                    function countHandle(id,that) {
                        // this.$router.push({name: 'export'})
                        /!* generate workbook object from table *!/
                        var wb = XLSX.utils.table_to_book(document.querySelector(id));
                        /!* get binary string as output *!/
                        var wbout = XLSX.write(wb, {
                            bookType: 'xlsx',
                            bookSST: true,
                            type: 'array'
                        });
                        try {
                            FileSaver.saveAs(
                                new Blob([wbout], { type: 'application/octet-stream' }),
                                `未激活企业列表数据.xlsx`
                            );
                        } catch (e) {
                            if (typeof console !== 'undefined') console.log(e, wbout);
                        }
                        that.Tloading2 = false;
                        return wbout;
                    }
                }
                gofn2()

            },
            handleCreate() {
                this.$router.push({
                    path: '/user/usercreate',
                    query: {id: Math.random()}
                });
            },
            handlePass(row) {
                console.log('handlePass ', row);
                resetPassWord(row.id)
                    .then(res => {
                        if (res.code == 0) {
                            this.$message({
                                message: '密码重置成功',
                                type: 'success'
                            });
                        } else {
                            this.$message.error(res.msg);
                        }
                    })
                    .catch(err => {
                        console.log(err);
                    });
                //重置密码
            },
            handleFilter(type) {
                //搜索数据
                if (type == 0) {
                    this.filter = true;
                    this.initCorpList('1');
                } else {
                    this.filter = false;
                    this.filterForm.timeScopes = '';
                    this.filterForm.name = '';
                    this.initCorpList('1');
                }
            },
            // 当前的页码，改变时会触发
            handleCurrentChange: function (currentPage) {
                this.initCorpList(currentPage);
            },

            ShandleCurrentChange(currentPage){
                this.initStopCorpList(currentPage,this.sName);
            },
            handleView(row) {
                localStorage.setItem('corpID', row.id);
                this.$router.push({path: '/area/companyorder', query: {id: row.id}});
            },
            initCorpList(pageID) {
                let that = this;
                that.Tloading = true;
                var name = '';
                var timeScope = '';
                if (this.filter == true) {
                    name = this.filterForm.name;
                    timeScope = this.filterForm.timeScope;
                }
                //刷新页面
                that.loading = true;
                getCorpList(pageID, name, timeScope)
                    .then(data => {
                        that.loading = false;
                        var myData = data.data;
                        var pageData = data.page;
                        that.total = pageData.resultCount;
                        that.count = pageData.pageCount;
                        that.pageCurrent = pageData.pageCurrent;
                        that.size = pageData.pageLimit;
                        if (myData.length <= 0) {
                            var lenth = that.companyList.length;
                            that.companyList.splice(0, lenth);
                            that.count = data.page.pageCurrent;
                            that.pageCurrent = data.page.pageCount
                            that.total = data.page.pageCount
                        } else {
                            lenth = that.companyList.length;
                            that.companyList.splice(0, lenth);
                            //加入数据内容
                            for (let i of myData) {
                                var map = {
                                    id: i.id,
                                    companyrName: i.companyHsName,
                                    address: i.address,
                                    name: i.contactsName,
                                    phone: i.contactsPhone,
                                    contactphone: i.eb1,
                                    contact: i.eb2
                                };
                                that.companyList.push(map);
                            }
                            var pageData = data.page;
                            that.total = pageData.resultCount;
                            that.count = pageData.pageCount;
                            that.pageCurrent = pageData.pageCurrent;
                            that.size = pageData.pageLimit;
                        }
                        that.Tloading = false;
                    })
                    .catch(function (error) {
                        console.log(error);
                        that.loading = false;
                        that.Tloading = false;
                    });
            },
            //未注册企业
            handleExcelN() {
                /* generate workbook object from table */
                var wb = XLSX.utils.table_to_book(document.querySelector('#table-dataN'));
                /* get binary string as output */
                var wbout = XLSX.write(wb, {
                    bookType: 'xlsx',
                    bookSST: true,
                    type: 'array'
                });
                try {
                    FileSaver.saveAs(
                        new Blob([wbout], {type: 'application/octet-stream'}),
                        'sheetjs.xlsx'
                    );
                } catch (e) {
                    if (typeof console !== 'undefined') console.log(e, wbout);
                }
                return wbout;
            },
            handleFilterN(type) {
                //搜索数据
                if (type == 0) {
                    this.filterN = true;
                    this.initCorpListN('1');
                } else {
                    this.filterN = false;
                    this.filterFormN.name = '';
                    this.initCorpListN('1');
                }
            },
            // 当前的页码，改变时会触发
            handleCurrentChangeN: function (currentPage) {
                this.initCorpListN(currentPage);
            },
            initCorpListN(pageID) {
                let that = this;
                that.Tloading2 = true;
                var name = '';
                if (this.filterN == true) {
                    name = this.filterFormN.name;
                }
                //刷新页面
                that.loading = true;
                getCorpListN(pageID, name)
                    .then(data => {
                        that.loading = false;
                        var myData = data.data;
                        if (myData.length <= 0) {
                            var lenth = that.companyListN.length;
                            that.companyListN.splice(0, lenth);
                        } else {
                            lenth = that.companyListN.length;
                            that.companyListN.splice(0, lenth);
                            //加入数据内容
                            for (let i of myData) {
                                var map = {
                                    id: i.id,
                                    companyrName: i.companyName,
                                    address: i.address,
                                    tradeMode: i.tradeMode,
                                    responPerson: i.responPerson,
                                    responPersonOfficePhone: i.responPersonOfficePhone,
                                    responPersonPhone: i.responPersonPhone
                                };
                                that.companyListN.push(map);
                            }
                            var pageData = data.page;
                            that.totalN = pageData.resultCount;
                            that.countN = pageData.pageCount;
                            that.pageCurrentN = pageData.pageCurrent;
                            that.sizeN = pageData.pageLimit;
                        }
                        that.Tloading2 = false;
                    })
                    .catch(function (error) {
                        console.log(error);
                        that.loading = false;
                        that.Tloading2 = false;
                    });
            }
        },
    };
</script>
<style>
</style>
